package com.example.superoa.model.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.alibaba.fastjson.JSONArray;
import com.example.superoa.model.dao.DepartmentDao;
import com.example.superoa.model.mappers.DepartmentMapper;
import com.example.superoa.model.pojos.Department;


@Service
@Transactional(rollbackFor=Exception.class)
public class DepartmentService {
	@Autowired
	private DepartmentMapper department;
	@Autowired
	private DepartmentDao departmentDao;
	//查询部门信息
	public List<Department> departmentAll(){
		return department.departmentAll();
	}
	//获取编辑数据
	public Department departmentById(int depart_id) {
		return department.departmentById(depart_id);
	}
	//添加部门
	public void adddepartment(Department d) {
		departmentDao.save(d);
	}
	//删除部门根据id
	public void deletedepartmentid(int depart_id){
		System.err.println(depart_id);
		departmentDao.deleteById(depart_id);
	}
	//修改
	public void xiugai(Department dd) {
		Department d = departmentDao.findById(dd.getDepart_id()).get();
		d.setDepartName(dd.getDepartName());
		d.setDepartAddress(dd.getDepartAddress());
	}
	
	/*public JSONArray selectPositive(String systemdate) {
		return department.selectPositive(systemdate);
	}
	public void updateStaffBypositive(int staff_id) {
		department.updateStaffBypositive(staff_id);
	}*/
}
